<template>
  <view class="ve-picker-wrapper">
    <!-- 弹框 -->
    <ve-popup v-if="isHaveRole" :model-value="modelValue" mode="bottom" @close="close">
      <view class="ve-picker-box">
        <view class="ve-picker-box-head">
          <view>请选择</view>
        </view>
        <view class="ve-picker-box-body">
          <ve-button v-if="btnRole1" class="btn-item" size="long" @click="onEvent('platoonCar')">排车</ve-button>
          <ve-button v-if="btnRole2" class="btn-item" size="long" @click="onEvent('addTempUse')">临时占用</ve-button>
          <ve-button v-if="btnRole3" class="btn-item" size="long" @click="onEvent('removeTempUse')">批量释放库存</ve-button>
        </view>
      </view>
    </ve-popup>
  </view>
</template>

<script>
  import { usePermission } from '@/hooks/usePermission'

  export default {
    name: 'handle-picker',
    props: {
      modelValue: Boolean,
    },
    data() {
      return {
        btnRole1: usePermission('svmsapp:stock.platoonCar'),
        btnRole2: usePermission('svmsapp:stock.tempUse'),
        btnRole3: usePermission('svmsapp:stock.batchRemoveTempUse'),
      }
    },
    computed: {
      isHaveRole() {
        return this.btnRole1 || this.btnRole2 || this.btnRole3
      },
    },
    methods: {
      close() {
        this.$emit('update:modelValue', false)
      },
      onEvent(event) {
        this.$emit('ok', event)
      },
    },
  }
</script>

<style lang="scss" scoped>
  .ve-picker-box {
    &-head {
      width: 100%;
      height: 44rpx;
      font-weight: 600;
      font-size: 36rpx;
      color: #191c27;
      line-height: 44rpx;
      text-align: center;
      margin-top: 32rpx;
      margin-bottom: 96rpx;
    }

    &-body {
      padding: 0 40rpx 56rpx;

      .btn-item {
        margin-bottom: 32rpx;
      }
    }
  }
</style>
